<template>
	<view class="row_scr">
		<scroll-view class="scroll_view" scroll-x :style="{ '--price': vuex_config.price }">
			<view class="scroll_item" v-for="(item, index) in dataList" :key="index" @click="goProdDetail(item)">
				<view class="scr_cont">
					<view class="img_item">
						<image mode="aspectFill" :src="item.logo"></image>
					</view>
					<view class="name">{{ item.name }}</view>
					<view class="price_main">
						<view class="new_price price_item">
							<text class="sign">￥</text>
							<text
								class="price_num">{{ item.r_price || item.r_price === 0? item.r_price : item.price }}</text>
						</view>
					</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		components: {},
		props: {
			parameter: {
				type: Object,
				default: () => {
					return {};
				}
			},
			dataList: {
				type: Array,
				default: []
			}
		},
		data() {
			return {};
		},
		filters: {
			priceFmt(price, isPoint = false) {
				let [priceInt, pricePoint] = price.split('.');
				return isPoint ? (pricePoint ? '.' + pricePoint : '') : priceInt;
			}
		},
		methods: {
			goProdDetail(item) {
				if (item.type == 2) {
					let currentTime = new Date().getTime();
					if (currentTime > item.end_date) {
						this.$toast({
							title: '活动已结束'
						});
						return;
					}
				}
				this.$toProd({
					...item,
					prodType: 1
				});
			}
		}
	};
</script>

<style scoped lang="scss">
	.row_scr {
		padding: 10rpx 24rpx;
		width: 100%;

		.scroll_view {
			white-space: nowrap;
			overflow: hidden;
			box-sizing: border-box;
			height: 266rpx;

			.scroll_item {
				background-color: #fff;
				display: inline-block;
				width: 174rpx;
				height: 100%;
				margin-right: 26rpx;

				.scr_cont {
					height: 100%;
					display: flex;
					flex-direction: column;
					justify-content: space-between;
				}

				.img_item {
					height: 174rpx;
				}

				.name {
					margin-top: 4rpx;
					white-space: nowrap;
					text-overflow: ellipsis;
					overflow: hidden;
					font-size: 26rpx;
					line-height: 36rpx;
				}

				.price_main {
					.price_item {
						color: var(--price);
						white-space: nowrap;
						overflow: hidden;
						text-overflow: ellipsis;

						.sign {
							font-size: 24rpx;
						}

						.price_num {
							font-size: 32rpx;
						}
					}
				}
			}
		}
	}
</style>
